package com.jdjc.subject.application.controller;

import com.alibaba.fastjson.JSON;
import com.jdjc.subject.common.entity.PageResult;
import com.jdjc.subject.infra.basic.entity.SubjectInfoEs;
import com.jdjc.subject.infra.basic.service.SubjectEsService;
import com.jdjc.subject.infra.basic.entity.UserInfo;
import com.jdjc.subject.infra.rpc.UserRPC;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
@Slf4j
public class TestFeignController {
    @Resource
    private UserRPC userRPC;
    @Resource
    private SubjectEsService subjectEsService;

    @GetMapping("/testFeign")
    public void testFeign(){
        UserInfo userInfo = userRPC.getUserInfo("o0kIv6148gj9CfZuHbkFiRqLLDTQ");
        log.info("testFeign userInfo:{}", userInfo);
    }
    @PostMapping("/test")
    public void test(){
        SubjectInfoEs subjectInfoEs = new SubjectInfoEs();
        subjectInfoEs.setKeyWord("redis");
        PageResult<SubjectInfoEs> pageResult = subjectEsService.querySubjectList(subjectInfoEs);
        log.info("pageResult:{}", JSON.toJSONString(pageResult));
    }

}
